﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace WorkOne.Domain.Model
{
    /// <summary>
    /// 订单信息
    /// </summary>
    [Table("Order")]
    public class Order
    {
        /// <summary>
        /// 订单Id
        /// </summary>
        [Key]
        public int OrderId { get; set; }

        [Required]
        public string? OrderCode { get; set; }

        [Required]
        public DateTime AddTime { get; set; }

        /// <summary>
        /// 商品数量（订单下购买的商品数量和）
        /// </summary>
        [Required]
        public int GoodsCount { get; set; }

        /// <summary>
        /// 总金额（单价*购买数量 累计和）
        /// </summary>
        [Required]
        [Column(TypeName = "decimal(10,2)")]
        public decimal PayTotal { get; set; }

        /// <summary>
        /// 逻辑删除标志（true:已删除，false：正常）
        /// </summary>
        [Required]
        public bool IsDel { get; set; }

        /// <summary>
        /// 运费
        /// </summary>
        [Required]
        [Column(TypeName = "decimal(10,2)")]
        public decimal Freight { get; set; }

        /// <summary>
        /// 订单来源（PC端订单，APP订单）
        /// </summary>
        [Required]
        public string? ComeFrom { get; set; }

        /// <summary>
        /// 订单下的商品列表（用于显示）
        /// </summary>
        [NotMapped]
        public List<Goods>? GoodsList { get; set; }

        public int Uid { get; set; }

        [ForeignKey("Uid")]
        public User User { get; set; }

        public int Aid { get; set; }

        [ForeignKey("Aid")]
        public Address Address { get; set; }

        /// <summary>
        /// 支付方式
        /// </summary>
        public PayType PayType { get; set; }

        [Required]
        public OrderState State { get; set; }

        /// <summary>
        /// 是否有发票
        /// </summary>
        public bool IsInvoice { get; set; }

        public string InvoiceDetail { get; set; }
    }
}